package ddd.ajava.chapter7.question4;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import net.sf.json.JSON;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import net.sf.json.JSONSerializer;

public class ObjectJsonMorpher {
	public static void main(String[] args) {
		Person person=new Person();
		person.setName("ddd");
		person.setAge(23);
		Address address=new Address("chonqqing","Hong Guang Street");
		person.setAddress(address);
		
		JSON json=JSONSerializer.toJSON(person);
		System.out.println(json.toString());
		
		Person p=(Person)JSONObject.toBean((JSONObject) json,Person.class);
		System.out.println("name:"+p.getName()+",age:"+p.getAge()+",address:"+p.getAddress().getStreet()+" "+p.getAddress().getProvince());
	}
}	
